
#include "OgreInitializeSettings.h"






OgreInitializeSettings::OgreInitializeSettings(){
	
	this->initNull();
}

OgreInitializeSettings::OgreInitializeSettings(bool log,Ogre::String name,Ogre::String first_arg){
	this->initNull();
	this->relative_path = this->getRelativePath(first_arg);
	this->uselog = log;
	this->name = name;
}


OgreInitializeSettings::~OgreInitializeSettings(){

	//general

	delete this->subsystems;

	if(this->manual_plugin_feed_count > 0){
		delete [] this->manual_plugin_feed;
	}

	//renderWindow

	delete [] this->window_size;

	if(this->graphic_setting_count > 0){
		delete [] this->graphic_setting_description;
		delete [] this->graphic_setting_value;
	}
	
	//physics

	delete this->bounds;

}

void OgreInitializeSettings::initNull(){


	//general
	this->subsystems = new std::vector<Ogre::String> ();	

	this->uselog = true;
	this->name = "";
	this->config_file_dir = "";
	this->plugin_file_dir = "";
	this->manual_plugin_feed = NULL;
	this->manual_plugin_feed_count = -1;

	this->METER = 1.0f;
	this->METERTOWU = 1 / METER;
	this->METERSQR = Ogre::Math::Sqr(this->METER);

	//renderWindow

	this->show_graphic_setting_dialog = false;
	this->window_size = new short [2];
	this->window_size[0] = 0;
	this->window_size[1] = 0;
	this->window_fullsize = false;
	this->graphic_setting_count = -1;
	this->graphic_setting_description = NULL;
	this->graphic_setting_value = NULL;
	
	//Physics

	this->gravity = 0;
	this->bounds = NULL;

	//inputs

	this->capture_keyboard = false;
	this->capture_mouse = false;
	this->capture_joystick = false;

	this->debug_camera_move_speed = 0.0f;
	this->debug_camera_rotate_speed = 0.0f;

	//menuHandler

	this->hintTimeout	= 0;
	this->stdfont		= "";
	this->stdskin		= "";
	
	//sounds

	this->max_sound_channel_count		= 200;
	
	this->SPEED_OF_SOUND				= 342.4f;
	this->SQUARED_SPEED_OF_SOUND        = 117237;

	this->sound_min_distance			= 10;
	this->sound_max_distance			= 1000;

	this->sound_pitch					= 1.0f;
	this->sound_volume					= 1.0f;
	this->sound_distance_effect_scale	= 0.5f;
	this->sound_doppler_effect_scale	= 1.0f;
	this->sound_rolloff_scale			= 0.1f;


}

void OgreInitializeSettings::initStd(){

	//general

	this->manual_plugin_feed_count = 4;
	this->manual_plugin_feed = new Ogre::String [this->manual_plugin_feed_count];

	this->manual_plugin_feed[0] = "RenderSystem_Direct3D9";
    this->manual_plugin_feed[1] = "Plugin_ParticleFX";
    this->manual_plugin_feed[2] = "Plugin_CgProgramManager";
    this->manual_plugin_feed[3] = "Plugin_OctreeSceneManager"; 

	//renderWindow

	this->window_size[0] = 800;
	this->window_size[1] = 600;

	this->graphic_setting_count = 2;
	this->graphic_setting_description = new Ogre::String [this->graphic_setting_count];
	this->graphic_setting_value = new Ogre::String [this->graphic_setting_count];

	this->graphic_setting_description[0] = "FSAA";this->graphic_setting_value[0] = "0";
	this->graphic_setting_description[1] = "vsync";this->graphic_setting_value[1] = "true";


	//physics

	this->gravity = 9.81f;

	//menuHandler

	this->hintTimeout = 5000;
}

Ogre::String OgreInitializeSettings::getRelativePath(Ogre::String path){

	Ogre::String help = path;

	for(int i = 0; i < 3;i++){
		
		help = help.substr(0,help.find_last_of('\\'));
	}
	return help + "\\Resources";
}